$(document).ready(function () {
    var bDate;
    var eDate;
    allClazz();
    function initTable(){
        var table=$("#table_show");
        table.empty("");
        table.append("<tr><td>日期</td></tr><tr><td>结对冠军</td></tr><tr><td>竞赛冠军</td></tr>");
    }
    $("#b_search").click(function() {
        var clazzId=$("#selectClazz").val();
        bDate=$("#b_Date").val();
        eDate=$("#e_Date").val();
        var search={
            clazzId:clazzId,
            bDate:bDate,
            eDate:eDate
        }
        $.ajax({
            type:"get",
            data:search,
            url:"/excel/getWinner",
            dataType:"json",
            success:function (data) {
                initTable();
                var tableRow = $("#table_show").find("tr");
                for(var j in data){
                    for (var i = 0, len = tableRow.length; i < len; i++) {
                        if(i==0){
                            var row = $(tableRow[i]);
                            row.append("<td align='center'>"+data[j].date+"</td>")
                        }else {
                            if(i==1){
                                var row=$(tableRow[i]);
                                row.append("<td align='center'>"+data[j].teamWinnerName+"</td>")
                            }else {
                                var row=$(tableRow[i]);
                                row.append("<td align='center'>"+data[j].selfWinnerName+"</td>")
                            }
                        }
                    }
                }
            },
            error:function () {
                alert("未找到相应数据！")
            }

        })
    });

    function allClazz() {
        $.ajax({
            type: "GET",
            url: "/excel/getAllClazz",
            dataType: "json",
            success: function (data) {
                if (data != null || data != "") {
                    var sClazz = $("#selectClazz");
                    for (var i in data) {
                        if(i==0){
                            sClazz.append("<option selected='selected' value=" + data[i].id + ">" + data[i].name + "</option>");
                        }
                        else {
                            sClazz.append("<option value=" + data[i].id + ">" + data[i].name + "</option>");
                        }

                    }
                }
            }
        })
    }
})